import request from '../utils/request'
import type { AxiosResponse } from 'axios'
import type { ApiResponse, LoginParams, UserInfo } from '../types/api'

// 登录接口
export function login(data: LoginParams): Promise<ApiResponse<UserInfo>> {
  return request({
    url: '/sos/dl/login', // 确保使用正确的 URL
    method: 'post',
    params: data
  })
}

// 获取用户信息
export function getUserInfo(): Promise<AxiosResponse<ApiResponse<UserInfo>>> {
  return request({
    url: '/user/info',
    method: 'get'
  })
}

// 退出登录
export function logout(): Promise<AxiosResponse<ApiResponse<null>>> {
  return request({
    url: '/logout',
    method: 'get'
  })
}
